#!/bin/bash

echo "🧹 清理旧的单模块结构文件..."

echo "删除旧的源码目录..."
if [ -d "src" ]; then
    rm -rf "src"
    echo "✅ 删除 src 目录"
fi

echo "删除旧的target目录..."
if [ -d "target" ]; then
    rm -rf "target"
    echo "✅ 删除 target 目录"
fi

echo "删除旧的插件目录..."
if [ -d "greeting-plugin" ]; then
    rm -rf "greeting-plugin"
    echo "✅ 删除 greeting-plugin 目录"
fi

echo "删除旧的构建脚本..."
if [ -f "build-plugin.bat" ]; then
    rm "build-plugin.bat"
    echo "✅ 删除 build-plugin.bat"
fi

if [ -f "build-plugin.sh" ]; then
    rm "build-plugin.sh"
    echo "✅ 删除 build-plugin.sh"
fi

if [ -f "start-app.bat" ]; then
    rm "start-app.bat"
    echo "✅ 删除 start-app.bat"
fi

if [ -f "test-plugin.bat" ]; then
    rm "test-plugin.bat"
    echo "✅ 删除 test-plugin.bat"
fi

echo "删除旧的备份文件..."
if [ -f "pom.xml.backup" ]; then
    rm "pom.xml.backup"
    echo "✅ 删除 pom.xml.backup"
fi

echo ""
echo "🎉 清理完成！现在项目结构为标准的Maven多模块架构。"
echo "📁 当前模块结构:"
echo "  - pf4j-api: 扩展点接口模块"
echo "  - pf4j-host: 宿主应用模块"
echo "  - pf4j-plugin-greeting: 插件模块"
echo ""
echo "💡 使用 ./build-multimodule.sh 来构建项目"
echo "💡 使用 ./start-multimodule-app.sh 来启动应用"
